﻿#include "mycombobox.h"

mycomboBox::mycomboBox(QWidget *parent) : QComboBox(parent)
{
    scanActivePort();
}

void mycomboBox::scanActivePort()
{
    QStringList serialPortsName;

    clear();
    foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
    {
        QString serialPortInfo = info.portName(); //+": "+info.description();
        serialPortsName << serialPortInfo;
    }
    addItems(serialPortsName);
}

void mycomboBox::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        scanActivePort();
        showPopup();
//        qDebug() << "mycomboBox click";
    }
}
